import { defineStore } from "pinia";
import { computed, ref } from "vue";

export const useCounterStore = defineStore ('counter',()=>{
  // 组合式API 写法
  const totalCount = ref(100)
  const dobuleCount = computed(()=>totalCount.value*2)

  // 修改
  const addCount = ()=> {
    totalCount.value++
  } 
  // 返回
  return {totalCount,dobuleCount,addCount} 
},{
  // 新的 usistorage 插件持久化配置
  unistorage:{
    key:'hm-counter',
    paths:['totalCount']
  }
})
